From 1f7e5c06102ddb073620496fe2e8a7df74fd195d Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sun, 1 Apr 2001 04:05:42 +0000 Subject: [PATCH] fixed a bunch of notifications, added reference counts around emissions Sun Apr 1 03:28:14 2001 Tim Janik * gtk/gtkwidget.c: fixed a bunch of notifications, added reference counts around emissions where the widget is used afterwards. added freeze/thaws around multiple properties being notified. (_gtk_widget_get_aux_info): cleanups. * gtk/gtksettings.c (gtk_settings_install_property): provide default parsing functions for gdkcolor, enums and flags. * gtk/gtkwindow.[hc]: partially reverted patch from havoc, applied by owen. kept a flag in GtkWindowGeometryInfo to handle user resetting default sizes. cleaned up ZVT comments. bunch of assorted bug fixes, notification fixes. (_gtk_window_reposition): make this a really internal function. * gtk/testgtk.c: fixups. --- ChangeLog | 20 + ChangeLog.pre-2-0 | 20 + ChangeLog.pre-2-10 | 20 + ChangeLog.pre-2-2 | 20 + ChangeLog.pre-2-4 | 20 + ChangeLog.pre-2-6 | 20 + ChangeLog.pre-2-8 | 20 + docs/reference/gtk/gtk.hierarchy | 1 - docs/reference/gtk/tmpl/gtkcontainer.sgml | 4 +- docs/reference/gtk/tmpl/gtklayout.sgml | 20 + docs/reference/gtk/tmpl/gtkrc.sgml | 1 + docs/reference/gtk/tmpl/gtksignal.sgml | 165 ++++--- docs/reference/gtk/tmpl/gtkspinbutton.sgml | 115 +++++ docs/reference/gtk/tmpl/gtktypeutils.sgml | 20 +- gtk/gtksettings.c | 15 +- gtk/gtkwidget.c | 104 ++--- gtk/gtkwindow.c | 483 ++++----------------- gtk/gtkwindow.h | 34 +- gtk/testgtk.c | 13 +- tests/testgtk.c | 13 +- 20 files changed, 544 insertions(+), 584 deletions(-) diff --git a/ChangeLog b/ChangeLog index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index d76e3e617d..cf1ced0006 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,23 @@ +Sun Apr 1 03:28:14 2001 Tim Janik + + * gtk/gtkwidget.c: fixed a bunch of notifications, added + reference counts around emissions where the widget is used afterwards. + added freeze/thaws around multiple properties being notified. + (_gtk_widget_get_aux_info): cleanups. + + * gtk/gtksettings.c (gtk_settings_install_property): provide + default parsing functions for gdkcolor, enums and flags. + + * gtk/gtkwindow.[hc]: partially reverted patch from havoc, + applied by owen. + kept a flag in GtkWindowGeometryInfo to handle user + resetting default sizes. + cleaned up ZVT comments. + bunch of assorted bug fixes, notification fixes. + (_gtk_window_reposition): make this a really internal function. + + * gtk/testgtk.c: fixups. + 2001-03-31 Hans Breuer * config.h.win32.in : disable USE_MMX for msvc build cause diff --git a/docs/reference/gtk/gtk.hierarchy b/docs/reference/gtk/gtk.hierarchy index 601aa73ff2..4655ff729f 100644 --- a/docs/reference/gtk/gtk.hierarchy +++ b/docs/reference/gtk/gtk.hierarchy @@ -6,7 +6,6 @@ GObject GdkPixmap GdkColormap GtkSettings - GtkRcStyle GtkObject GtkWidget GtkMisc diff --git a/docs/reference/gtk/tmpl/gtkcontainer.sgml b/docs/reference/gtk/tmpl/gtkcontainer.sgml index bf2233efbb..5fd8635c62 100644 --- a/docs/reference/gtk/tmpl/gtkcontainer.sgml +++ b/docs/reference/gtk/tmpl/gtkcontainer.sgml @@ -407,12 +407,12 @@ GtkContainer @container: the object which received the signal. @widget: - + - + diff --git a/docs/reference/gtk/tmpl/gtklayout.sgml b/docs/reference/gtk/tmpl/gtklayout.sgml index 983af247ff..4a834ad340 100644 --- a/docs/reference/gtk/tmpl/gtklayout.sgml +++ b/docs/reference/gtk/tmpl/gtklayout.sgml @@ -123,3 +123,23 @@ GtkLayout @arg1: @arg2: + + + + + + + + + + + + + + + + + + + + diff --git a/docs/reference/gtk/tmpl/gtkrc.sgml b/docs/reference/gtk/tmpl/gtkrc.sgml index fe52fbe8a2..041bbddd55 100644 --- a/docs/reference/gtk/tmpl/gtkrc.sgml +++ b/docs/reference/gtk/tmpl/gtkrc.sgml @@ -496,6 +496,7 @@ This can later be composited together with other #GtkRcStyle structures to form a #GtkStyle. +@parent_instance: @name: @bg_pixmap_name: @font_desc: diff --git a/docs/reference/gtk/tmpl/gtksignal.sgml b/docs/reference/gtk/tmpl/gtksignal.sgml index 1bb805c8ba..1a5a4f3e27 100644 --- a/docs/reference/gtk/tmpl/gtksignal.sgml +++ b/docs/reference/gtk/tmpl/gtksignal.sgml @@ -289,7 +289,7 @@ you don't want a return value. the callbacks. - + Given the name of the signal and the type of object it connects to, get the signal's identifying integer. Emitting the signal @@ -299,13 +299,12 @@ by number is somewhat faster than using the name each time. It also tries the ancestors of the given type. -@Returns: the signal's identifying number, or 0 if no signal was found. - @name: the signal's name, e.g. clicked. @object_type: the type that the signal operates on, e.g. #GTK_TYPE_BUTTON. +@Returns: the signal's identifying number, or 0 if no signal was found. - + Given the signal's identifier, find its name. @@ -313,9 +312,8 @@ Given the signal's identifier, find its name. Two different signals may have the same name, if they have differing types. -@Returns: the signal name, or NULL if the signal number was invalid. - @signal_id: the signal's identifying number. +@Returns: the signal name, or NULL if the signal number was invalid. @@ -383,7 +381,7 @@ an array of GtkArgs instead of using C's varargs mechanism. followed by one which is a pointer to the return type. - + This function aborts a signal's current emission. @@ -397,11 +395,11 @@ It will print a warning if used on a signal which isn't being emitted. -@i: -@s: - @object: the object whose signal handlers you wish to stop. @signal_id: the signal identifier, as returned by gtk_signal_lookup(). + +@i: +@s: @@ -417,7 +415,7 @@ except it will lookup the signal id for you. @name: the name of the signal you wish to stop. - + Attach a function pointer and user data to a signal for a particular object. @@ -456,38 +454,38 @@ static void attach_print_signal(GtkButton* button, gint to_print) -@o: -@s: -@f: -@d: -@Returns: the connection id. - @object: the object associated with the signal, e.g. if a button is getting pressed, this is that button. @name: name of the signal. @func: function pointer to attach to the signal. @func_data: value to pass as to your function (through the marshaller). +@Returns: the connection id. + +@o: +@s: +@f: +@d: - + Attach a function pointer and user data to a signal so that this handler will be called after the other handlers. -@o: -@s: -@f: -@d: -@Returns: the unique identifier for this attachment: the connection id. - @object: the object associated with the signal. @name: name of the signal. @func: function pointer to attach to the signal. @func_data: value to pass as to your function (through the marshaller). +@Returns: the unique identifier for this attachment: the connection id. + +@o: +@s: +@f: +@d: - + This function is for registering a callback that will call another object's callback. That is, @@ -508,21 +506,21 @@ gtk_signal_connect_object(button, "clicked", gtk_widget_show, window); -@o: -@s: -@f: -@d: -@Returns: the connection id. - @object: the object which emits the signal. @name: the name of the signal. @func: the function to callback. @slot_object: the object to pass as the first parameter to func. (Though it pretends to take an object, you can really pass any gpointer as the #slot_object .) +@Returns: the connection id. + +@o: +@s: +@f: +@d: - + Attach a signal hook to a signal, passing in an alternate object as the first parameter, and guaranteeing @@ -530,16 +528,16 @@ that the default handler and all normal handlers are called first. -@o: -@s: -@f: -@d: -@Returns: the connection id. - @object: the object associated with the signal. @name: name of the signal. @func: function pointer to attach to the signal. @slot_object: the object to pass as the first parameter to #func. +@Returns: the connection id. + +@o: +@s: +@f: +@d: @@ -628,98 +626,95 @@ should signal the removal of this signal. @name: name of the signal. - + Destroy a user-defined handler connection. - @object: the object which the handler pertains to. @handler_id: the connection id. - + Destroy all connections for a particular object, with the given function-pointer and user-data. -@o: -@f: -@d: - @object: the object which emits the signal. @func: the function pointer to search for. @data: the user data to search for. + +@o: +@f: +@d: - + Destroy all connections for a particular object, with the given user-data. -@o: -@d: - @object: the object which emits the signal. @data: the user data to search for. + +@o: +@d: - + Prevent an user-defined handler from being invoked. All other signal processing will go on as normal, but this particular handler will ignore it. - @object: the object which emits the signal to block. @handler_id: the connection id. - + Prevent a user-defined handler from being invoked, by reference to the user-defined handler's function pointer and user data. (It may result in multiple hooks being blocked, if you've called connect multiple times.) -@o: -@f: -@d: - @object: the object which emits the signal to block. @func: the function pointer of the handler to block. @data: the user data of the handler to block. + +@o: +@f: +@d: - + Prevent all user-defined handlers with a certain user data from being invoked. -@o: -@d: - @object: the object which emits the signal we want to block. @data: the user data of the handlers to block. + +@o: +@d: - + Undo a block, by connection id. Note that undoing a block doesn't necessarily make the hook callable, because if you block a hook twice, you must unblock it twice. - @object: the object which emits the signal we want to unblock. @handler_id: the emission handler identifier, as returned by gtk_signal_connect(), etc. - + Undo a block, by function pointer and data. Note that undoing a block doesn't @@ -727,29 +722,29 @@ necessarily make the hook callable, because if you block a hook twice, you must unblock it twice. -@o: -@f: -@d: - @object: the object which emits the signal we want to unblock. @func: the function pointer to search for. @data: the user data to search for. + +@o: +@f: +@d: - + Undo block(s), to all signals for a particular object with a particular user-data pointer -@o: -@d: - @object: the object which emits the signal we want to unblock. @data: the user data to search for. + +@o: +@d: - + Returns a connection id corresponding to a given signal id and object. @@ -760,36 +755,36 @@ may opt to not emit the signal if no one is attached anyway, thus saving the cost of building the arguments. -@i: -@s: -@b: -@Returns: the connection id, if a connection was found. 0 otherwise. - @object: the object to search for the desired user-defined handler. @signal_id: the number of the signal to search for. @may_be_blocked: whether it is acceptable to return a blocked handler. +@Returns: the connection id, if a connection was found. 0 otherwise. + +@i: +@s: +@b: - + Returns a connection id corresponding to a given signal id, object, function pointer and user data. -@o: -@s: -@b: -@f: -@d: -@Returns: the connection id, if a handler was found. 0 otherwise. - @object: the object to search for the desired handler. @signal_id: the number of the signal to search for. @may_be_blocked: whether it is acceptable to return a blocked handler. @func: the function pointer to search for. @data: the user data to search for. +@Returns: the connection id, if a handler was found. 0 otherwise. + +@o: +@s: +@b: +@f: +@d: diff --git a/docs/reference/gtk/tmpl/gtkspinbutton.sgml b/docs/reference/gtk/tmpl/gtkspinbutton.sgml index 040f725df9..e01764f9b7 100644 --- a/docs/reference/gtk/tmpl/gtkspinbutton.sgml +++ b/docs/reference/gtk/tmpl/gtkspinbutton.sgml @@ -172,6 +172,114 @@ Creates a new #GtkSpinButton. @Returns: a #GtkWidget. + + + + + +@spin_button: +@adjustment: + + + + + + + +@spin_button: +@Returns: + + + + + + + +@spin_button: +@digits: + + + + + + + +@spin_button: +@Returns: + + + + + + + +@spin_button: +@Returns: + + + + + + + +@spin_button: +@value: + + + + + + + +@spin_button: +@policy: + + + + + + + +@spin_button: +@numeric: + + + + + + + +@spin_button: +@direction: +@increment: + + + + + + + +@spin_button: +@wrap: + + + + + + + +@spin_button: +@snap_to_ticks: + + + + + + + +@spin_button: + + @@ -196,6 +304,13 @@ Creates a new #GtkSpinButton. @spinbutton: the object which received the signal. @Returns: + + + + + +@spinbutton: the object which received the signal. + the #GtkAdjustment that defines a spin button's main properties. diff --git a/docs/reference/gtk/tmpl/gtktypeutils.sgml b/docs/reference/gtk/tmpl/gtktypeutils.sgml index 16a7e543fe..6295e2dfa1 100644 --- a/docs/reference/gtk/tmpl/gtktypeutils.sgml +++ b/docs/reference/gtk/tmpl/gtktypeutils.sgml @@ -560,33 +560,30 @@ Create a new, unique type. @type_info: must not be null, and @type_info->type_name must also not be null. - + -@Returns: a pointer to the name of a type, or NULL if it has none. - @type: a GtkType +@Returns: a pointer to the name of a type, or NULL if it has none. - + Get the internal representation of a type given its name. -@Returns: a GtkType - @name: the name of a gtk type +@Returns: a GtkType - + -@Returns: the GtkType of the parent - @type: a GtkType +@Returns: the GtkType of the parent @@ -611,16 +608,15 @@ has all the proper initializers called. @Returns: gpointer to a GtkTypeObject - + Look in the type hierarchy to see if @type has @is_a_type among its ancestors. Do so with a simple lookup, not a loop. -@Returns: - @type: GtkType @is_a_type: GtkType +@Returns: diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index 2bfce3a933..5d8da2a789 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -381,10 +381,23 @@ void gtk_settings_install_property (GtkSettings *settings, GParamSpec *pspec) { + GtkRcPropertyParser parser = NULL; + g_return_if_fail (GTK_IS_SETTINGS (settings)); g_return_if_fail (G_IS_PARAM_SPEC (pspec)); + + /* convenient automatic parser selection + */ + if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GTK_TYPE_GDK_COLOR) + parser = gtk_rc_property_parse_color; + else if (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)) == G_TYPE_ENUM && + G_TYPE_IS_DERIVED (G_PARAM_SPEC_VALUE_TYPE (pspec))) + parser = gtk_rc_property_parse_enum; + else if (G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (pspec)) == G_TYPE_FLAGS && + G_TYPE_IS_DERIVED (G_PARAM_SPEC_VALUE_TYPE (pspec))) + parser = gtk_rc_property_parse_flags; - settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, NULL); + settings_install_property_parser (GTK_SETTINGS_GET_CLASS (settings), pspec, parser); } void diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 5500183dee..b3c485ab12 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -198,7 +198,6 @@ static void gtk_widget_propagate_hierarchy_changed (GtkWidget *widget, static gboolean gtk_widget_real_activate_mnemonic (GtkWidget *widget, gboolean group_cycling); -static GtkWidgetAuxInfo* gtk_widget_aux_info_new (void); static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info); static void gtk_widget_do_uposition (GtkWidget *widget); @@ -1331,6 +1330,8 @@ gtk_widget_unparent (GtkWidget *widget) /* keep this function in sync with gtk_menu_detach() */ + g_object_freeze_notify (G_OBJECT (widget)); + /* unset focused and default children properly, this code * should eventually move into some gtk_window_unparent_branch() or * similar function. @@ -1443,8 +1444,8 @@ gtk_widget_unparent (GtkWidget *widget) gtk_widget_set_parent_window (widget, NULL); gtk_signal_emit (GTK_OBJECT (widget), widget_signals[PARENT_SET], old_parent); gtk_widget_propagate_hierarchy_changed (widget, NULL); - g_object_notify (G_OBJECT (widget), "parent"); + g_object_thaw_notify (G_OBJECT (widget)); gtk_widget_unref (widget); } @@ -1528,10 +1529,12 @@ gtk_widget_show (GtkWidget *widget) if (!GTK_WIDGET_VISIBLE (widget)) { + g_object_ref (G_OBJECT (widget)); if (!GTK_WIDGET_TOPLEVEL (widget)) gtk_widget_queue_resize (widget); gtk_signal_emit (GTK_OBJECT (widget), widget_signals[SHOW]); g_object_notify (G_OBJECT (widget), "visible"); + g_object_unref (G_OBJECT (widget)); } } @@ -2930,9 +2933,10 @@ gtk_widget_grab_focus (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); + g_object_ref (G_OBJECT (widget)); gtk_signal_emit (GTK_OBJECT (widget), widget_signals[GRAB_FOCUS]); - g_object_notify (G_OBJECT (widget), "has_focus"); + g_object_unref (G_OBJECT (widget)); } static void @@ -3075,10 +3079,10 @@ gtk_widget_grab_default (GtkWidget *widget) if (window && gtk_type_is_a (GTK_WIDGET_TYPE (window), window_type)) { gtk_window_set_default (GTK_WINDOW (window), widget); - g_object_notify (G_OBJECT (window), "has_default"); + g_object_notify (G_OBJECT (widget), "has_default"); } else - g_warning("gtk_widget_grab_default() called on a widget not within a GtkWindow"); + g_warning (G_STRLOC ": widget not within a GtkWindow"); } /** @@ -3189,9 +3193,9 @@ gtk_widget_set_app_paintable (GtkWidget *widget, if (GTK_WIDGET_DRAWABLE (widget)) gtk_widget_queue_clear (widget); - } - g_object_notify (G_OBJECT (widget), "app_paintable"); + g_object_notify (G_OBJECT (widget), "app_paintable"); + } } /** @@ -3367,8 +3371,6 @@ gtk_widget_set_style (GtkWidget *widget, } gtk_widget_set_style_internal (widget, style, initial_emission); - - g_object_notify (G_OBJECT (widget), "style"); } /** @@ -3734,6 +3736,9 @@ gtk_widget_set_style_internal (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (style != NULL); + g_object_ref (G_OBJECT (widget)); + g_object_freeze_notify (G_OBJECT (widget)); + if (widget->style != style || initial_emission) { PangoContext *context = gtk_widget_peek_pango_context (widget); @@ -3778,11 +3783,12 @@ gtk_widget_set_style_internal (GtkWidget *widget, } } else if (initial_emission) - { - gtk_signal_emit (GTK_OBJECT (widget), - widget_signals[STYLE_SET], - NULL); - } + gtk_signal_emit (GTK_OBJECT (widget), + widget_signals[STYLE_SET], + NULL); + g_object_notify (G_OBJECT (widget), "style"); + g_object_thaw_notify (G_OBJECT (widget)); + g_object_unref (G_OBJECT (widget)); } static void @@ -4117,15 +4123,17 @@ gtk_widget_do_uposition (GtkWidget *widget) GtkWidgetAuxInfo *aux_info =_gtk_widget_get_aux_info (widget, FALSE); if (GTK_IS_WINDOW (widget) && aux_info->x_set && aux_info->y_set) - gtk_window_reposition (GTK_WINDOW (widget), aux_info->x, aux_info->y); + _gtk_window_reposition (GTK_WINDOW (widget), aux_info->x, aux_info->y); if (GTK_WIDGET_VISIBLE (widget) && widget->parent) gtk_widget_size_allocate (widget, &widget->allocation); + g_object_freeze_notify (G_OBJECT (widget)); if (aux_info->x_set) g_object_notify (G_OBJECT (widget), "x"); if (aux_info->y_set) g_object_notify (G_OBJECT (widget), "y"); + g_object_thaw_notify (G_OBJECT (widget)); } /** @@ -4162,8 +4170,6 @@ gtk_widget_set_uposition (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); aux_info =_gtk_widget_get_aux_info (widget, TRUE); - - /* keep this in sync with gtk_window_set_location() */ if (x > -2) { @@ -4225,20 +4231,25 @@ gtk_widget_set_usize (GtkWidget *widget, g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WIDGET (widget)); + g_object_freeze_notify (G_OBJECT (widget)); + aux_info =_gtk_widget_get_aux_info (widget, TRUE); if (width > -2) - aux_info->width = width; + { + g_object_notify (G_OBJECT (widget), "width"); + aux_info->width = width; + } if (height > -2) - aux_info->height = height; + { + g_object_notify (G_OBJECT (widget), "height"); + aux_info->height = height; + } if (GTK_WIDGET_VISIBLE (widget)) gtk_widget_queue_resize (widget); - if (width > -2) - g_object_notify (G_OBJECT (widget), "width"); - if (height > -2) - g_object_notify (G_OBJECT (widget), "height"); + g_object_thaw_notify (G_OBJECT (widget)); } /** @@ -5204,7 +5215,7 @@ gtk_widget_propagate_state (GtkWidget *widget, * Return value: the #GtkAuxInfo structure for the widget, or * %NULL if @create is %FALSE and one doesn't already exist. **/ -GtkWidgetAuxInfo * +GtkWidgetAuxInfo* _gtk_widget_get_aux_info (GtkWidget *widget, gboolean create) { @@ -5213,45 +5224,24 @@ _gtk_widget_get_aux_info (GtkWidget *widget, aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info); if (!aux_info && create) { - aux_info = gtk_widget_aux_info_new (); + if (!aux_info_mem_chunk) + aux_info_mem_chunk = g_mem_chunk_new ("widget aux info mem chunk", + sizeof (GtkWidgetAuxInfo), + 1024, G_ALLOC_AND_FREE); + aux_info = g_chunk_new (GtkWidgetAuxInfo, aux_info_mem_chunk); + + aux_info->width = -1; + aux_info->height = -1; + aux_info->x = 0; + aux_info->y = 0; + aux_info->x_set = FALSE; + aux_info->y_set = FALSE; gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_aux_info, aux_info); - - aux_info->width = aux_info->height = -1; - aux_info->x = aux_info->y = 0; - aux_info->x_set = aux_info->y_set = FALSE; } return aux_info; } -/***************************************** - * gtk_widget_aux_info_new: - * - * arguments: - * - * results: - *****************************************/ - -static GtkWidgetAuxInfo* -gtk_widget_aux_info_new (void) -{ - GtkWidgetAuxInfo *aux_info; - - if (!aux_info_mem_chunk) - aux_info_mem_chunk = g_mem_chunk_new ("widget aux info mem chunk", - sizeof (GtkWidgetAuxInfo), - 1024, G_ALLOC_AND_FREE); - - aux_info = g_chunk_new (GtkWidgetAuxInfo, aux_info_mem_chunk); - - aux_info->x = -1; - aux_info->y = -1; - aux_info->width = 0; - aux_info->height = 0; - - return aux_info; -} - /***************************************** * gtk_widget_aux_info_destroy: * diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index f1dacda4b2..d5ec03dfac 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -49,11 +49,6 @@ #include "gtkiconfactory.h" #include "gtkintl.h" -/* TODO: remove this define and assorted code in 1.3 and fix up the - * real culprits. - */ -#define FIXME_ZVT_ME_HARDER - enum { SET_FOCUS, FRAME_EVENT, @@ -76,7 +71,7 @@ enum { PROP_DEFAULT_WIDTH, PROP_DEFAULT_HEIGHT, PROP_DESTROY_WITH_PARENT, - + LAST_ARG }; @@ -87,17 +82,19 @@ typedef struct { gint height; } GtkWindowLastGeometryInfo; -typedef struct { +struct _GtkWindowGeometryInfo +{ /* Properties that the app has set on the window */ GdkGeometry geometry; /* Geometry hints */ GdkWindowHints mask; GtkWidget *widget; /* subwidget to which hints apply */ - gint width; /* gtk_window_set_default_size () */ + gint width; /* Default size */ gint height; + guint may_shrink : 1; /* one-shot auto_shrink behaviour after set_default_size */ GtkWindowLastGeometryInfo last; -} GtkWindowGeometryInfo; +}; typedef struct { GtkWindow *window; @@ -166,11 +163,11 @@ static void gtk_window_constrain_size (GtkWindow *window, static void gtk_window_compute_hints (GtkWindow *window, GdkGeometry *new_geometry, guint *new_flags); -static gboolean gtk_window_compute_reposition (GtkWindow *window, - gint new_width, - gint new_height, - gint *x, - gint *y); +static gint gtk_window_compute_reposition (GtkWindow *window, + gint new_width, + gint new_height, + gint *x, + gint *y); static void gtk_window_read_rcfiles (GtkWidget *widget, GdkEventClient *event); @@ -186,7 +183,6 @@ static void gtk_window_transient_parent_unrealized (GtkWidget *parent, static GtkWindowGeometryInfo* gtk_window_get_geometry_info (GtkWindow *window, gboolean create); -static void gtk_window_geometry_destroy (GtkWindowGeometryInfo *info); static GSList *toplevel_list = NULL; @@ -432,6 +428,8 @@ gtk_window_init (GtkWindow *window) window->title = NULL; window->wmclass_name = g_strdup (g_get_prgname ()); window->wmclass_class = g_strdup (gdk_progclass); + window->wm_role = NULL; + window->geometry_info = NULL; window->type = GTK_WINDOW_TOPLEVEL; window->focus_widget = NULL; window->default_widget = NULL; @@ -1091,9 +1089,9 @@ gtk_window_remove_embedded_xid (GtkWindow *window, guint xid) } void -gtk_window_reposition (GtkWindow *window, - gint x, - gint y) +_gtk_window_reposition (GtkWindow *window, + gint x, + gint y) { GtkWindowGeometryInfo *info; @@ -1318,24 +1316,13 @@ gtk_window_set_destroy_with_parent (GtkWindow *window, g_object_notify (G_OBJECT (window), "destroy_with_parent"); } -static void -gtk_window_geometry_destroy (GtkWindowGeometryInfo *info) -{ - if (info->widget) - gtk_signal_disconnect_by_func (GTK_OBJECT (info->widget), - GTK_SIGNAL_FUNC (gtk_widget_destroyed), - &info->widget); - g_free (info); -} - static GtkWindowGeometryInfo* gtk_window_get_geometry_info (GtkWindow *window, gboolean create) { GtkWindowGeometryInfo *info; - info = gtk_object_get_data (GTK_OBJECT (window), "gtk-window-geometry"); - + info = window->geometry_info; if (!info && create) { info = g_new0 (GtkWindowGeometryInfo, 1); @@ -1346,11 +1333,8 @@ gtk_window_get_geometry_info (GtkWindow *window, info->last.height = -1; info->widget = NULL; info->mask = 0; - - gtk_object_set_data_full (GTK_OBJECT (window), - "gtk-window-geometry", - info, - (GtkDestroyNotify) gtk_window_geometry_destroy); + info->may_shrink = FALSE; + window->geometry_info = info; } return info; @@ -1470,33 +1454,22 @@ gtk_window_set_default_size (GtkWindow *window, info = gtk_window_get_geometry_info (window, TRUE); + g_object_freeze_notify (G_OBJECT (window)); if (width >= 0) - info->width = width; - if (height >= 0) - info->height = height; - - if (width >= 0) - g_object_notify (G_OBJECT (window), "width"); + { + info->width = width; + g_object_notify (G_OBJECT (window), "default_width"); + info->may_shrink = TRUE; + } if (height >= 0) - g_object_notify (G_OBJECT (window), "height"); - - if (GTK_WIDGET_REALIZED (window) && window->allow_grow) { - /* Resize as if the user had resized */ - GdkGeometry new_geometry; - GdkWindowHints new_flags; - - gtk_window_compute_hints (window, &new_geometry, &new_flags); - gtk_window_constrain_size (window, - &new_geometry, new_flags, - width, height, - &width, &height); - - gdk_window_resize (GTK_WIDGET (window)->window, - width, height); + info->height = height; + g_object_notify (G_OBJECT (window), "default_height"); + info->may_shrink = TRUE; } - else - gtk_widget_queue_resize (GTK_WIDGET (window)); + g_object_thaw_notify (G_OBJECT (window)); + + gtk_widget_queue_resize (GTK_WIDGET (window)); } static void @@ -1560,10 +1533,19 @@ gtk_window_finalize (GObject *object) g_free (window->title); g_free (window->wmclass_name); g_free (window->wmclass_class); + g_free (window->wm_role); g_hash_table_foreach_remove (mnemonic_hash_table, gtk_window_mnemonic_hash_remove, window); + if (window->geometry_info) + { + if (window->geometry_info->widget) + gtk_signal_disconnect_by_func (GTK_OBJECT (window->geometry_info->widget), + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &window->geometry_info->widget); + g_free (window->geometry_info); + } G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -1574,7 +1556,6 @@ gtk_window_show (GtkWidget *widget) GtkWindow *window = GTK_WINDOW (widget); GtkContainer *container = GTK_CONTAINER (window); gboolean need_resize; - gboolean was_realized; GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE); @@ -1587,6 +1568,7 @@ gtk_window_show (GtkWidget *widget) GtkAllocation allocation = { 0, 0 }; GdkGeometry new_geometry; guint width, height, new_flags; + gboolean was_realized; /* determine default size to initially show the window with */ gtk_widget_size_request (widget, NULL); @@ -1616,7 +1598,8 @@ gtk_window_show (GtkWidget *widget) } /* Must be done after the windows are realized, - so that the decorations can be read */ + * so that the decorations can be read + */ gtk_decorated_window_calculate_frame_size (window); if (!was_realized) @@ -2474,14 +2457,14 @@ gtk_window_move_resize (GtkWindow *window) GtkWindowLastGeometryInfo saved_last_info; GdkGeometry new_geometry; guint new_flags; - gboolean need_reposition; gint x, y; gint width, height; gint new_width, new_height; + gboolean need_reposition; gboolean default_size_changed = FALSE; gboolean hints_changed = FALSE; + gboolean may_shrink = window->auto_shrink; - g_return_if_fail (GTK_IS_WINDOW (window)); g_return_if_fail (GTK_WIDGET_REALIZED (window)); widget = GTK_WIDGET (window); @@ -2497,6 +2480,7 @@ gtk_window_move_resize (GtkWindow *window) info->last.height != new_height) { default_size_changed = TRUE; + may_shrink |= info->may_shrink; info->last.width = new_width; info->last.height = new_height; @@ -2505,6 +2489,7 @@ gtk_window_move_resize (GtkWindow *window) if (window->position == GTK_WIN_POS_CENTER_ALWAYS) window->use_uposition = TRUE; } + info->may_shrink = FALSE; /* Compute new set of hints for the window */ @@ -2520,10 +2505,10 @@ gtk_window_move_resize (GtkWindow *window) /* From the default size and the allocation, figure out the size * the window should be. */ - if (!window->auto_shrink && - (!default_size_changed || - (new_width <= widget->allocation.width && - new_height <= widget->allocation.height))) + if (!default_size_changed || + (!may_shrink && + new_width <= widget->allocation.width && + new_height <= widget->allocation.height)) { new_width = widget->allocation.width; new_height = widget->allocation.height; @@ -2572,7 +2557,6 @@ gtk_window_move_resize (GtkWindow *window) gtk_widget_size_allocate (widget, &allocation); gtk_widget_queue_draw (widget); -#ifdef FIXME_ZVT_ME_HARDER if ((default_size_changed || hints_changed) && (width != new_width || height != new_height)) { /* We could be here for two reasons @@ -2580,8 +2564,7 @@ gtk_window_move_resize (GtkWindow *window) * another resize. * 2) Our computation of default_size_changed was completely * screwed up, probably because one of our children - * is broken (i.e. changes requisition during - * size allocation). It's probably a zvt widget. + * is changed requisition during size allocation). * * For 1), we could just go ahead and ask for the * new size right now, but doing that for 2) @@ -2612,14 +2595,12 @@ gtk_window_move_resize (GtkWindow *window) /* we have to preserve the values and flags that are used * for computation of default_size_changed and hints_changed */ - info->last = saved_last_info; gtk_widget_queue_resize (widget); return; } -#endif /* FIXME_ZVT_ME_HARDER */ } /* Now set hints if necessary @@ -2743,9 +2724,9 @@ gtk_window_compare_hints (GdkGeometry *geometry_a, return FALSE; if ((flags_a & GDK_HINT_WIN_GRAVITY) && - (geometry_a->win_gravity != geometry_b->win_gravity)) + geometry_a->win_gravity != geometry_b->win_gravity) return FALSE; - + return TRUE; } @@ -2790,8 +2771,11 @@ _gtk_window_constrain_size (GtkWindow *window, gint *new_width, gint *new_height) { - GtkWindowGeometryInfo *info = (GtkWindowGeometryInfo *)gtk_object_get_data (GTK_OBJECT (window), "gtk-window-geometry"); - + GtkWindowGeometryInfo *info; + + g_return_if_fail (GTK_IS_WINDOW (window)); + + info = window->geometry_info; if (info) { GdkWindowHints flags = info->last.flags; @@ -2928,21 +2912,20 @@ gtk_window_compute_hints (GtkWindow *window, /* Compute a new position for the window based on a new * size. *x and *y will be set to the new coordinates. Returns - * TRUE if the window needs to be moved; + * TRUE if the window needs to be moved (and thus x and y got + * assigned) */ -static gboolean -gtk_window_compute_reposition (GtkWindow *window, - gint new_width, - gint new_height, - gint *x, - gint *y) +static gint +gtk_window_compute_reposition (GtkWindow *window, + gint new_width, + gint new_height, + gint *x, + gint *y) { - GtkWidget *widget; + GtkWidget *widget = GTK_WIDGET (window); GtkWindowPosition pos; GtkWidget *parent_widget; - gboolean result = FALSE; - - widget = GTK_WIDGET (window); + gboolean needs_move = FALSE; parent_widget = (GtkWidget*) window->transient_parent; @@ -2963,8 +2946,7 @@ gtk_window_compute_reposition (GtkWindow *window, *x = (screen_width - new_width) / 2; *y = (screen_height - new_height) / 2; - - result = TRUE; + needs_move = TRUE; } break; @@ -2977,9 +2959,8 @@ gtk_window_compute_reposition (GtkWindow *window, *x = ox + (parent_widget->allocation.width - new_width) / 2; *y = oy + (parent_widget->allocation.height - new_height) / 2; - - result = TRUE; - } + needs_move = TRUE; + } break; case GTK_WIN_POS_MOUSE: @@ -2993,37 +2974,40 @@ gtk_window_compute_reposition (GtkWindow *window, *y -= new_height / 2; *x = CLAMP (*x, 0, screen_width - new_width); *y = CLAMP (*y, 0, screen_height - new_height); - - result = TRUE; + needs_move = TRUE; } break; default: if (window->use_uposition) { GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE); + if (aux_info && aux_info->x_set && aux_info->y_set) { *x = aux_info->x; *y = aux_info->y; + needs_move = TRUE; } - - result = TRUE; } break; } - if (result) + if (needs_move) { GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, TRUE); - - aux_info->x_set = aux_info->y_set = TRUE; + + /* we handle necessary window positioning by hand here, + * so we can coalesce the window movement with possible + * resizes to get only one configure event. + */ + aux_info->x_set = TRUE; + aux_info->y_set = TRUE; aux_info->x = *x; aux_info->y = *y; - window->use_uposition = FALSE; } - return result; + return needs_move; } /*********************** @@ -3398,30 +3382,26 @@ gtk_window_unmaximize (GtkWindow *window) /** * gtk_window_set_resizeable: * @window: a #GtkWindow - * @setting: %TRUE if the user can resize this window + * @resizeable: %TRUE if the user can resize this window * * Sets whether the user can resize a window. Windows are user resizeable * by default. - * **/ void gtk_window_set_resizeable (GtkWindow *window, - gboolean setting) + gboolean resizeable) { g_return_if_fail (GTK_IS_WINDOW (window)); - if (setting) - gtk_window_set_policy (window, FALSE, TRUE, FALSE); - else - gtk_window_set_policy (window, FALSE, FALSE, TRUE); + gtk_window_set_policy (window, FALSE, resizeable, FALSE); } /** * gtk_window_get_resizeable: * @window: a #GtkWindow - * + * * Gets the value set by gtk_window_set_resizeable(). - * + * * Return value: %TRUE if the user can resize the window **/ gboolean @@ -3436,276 +3416,6 @@ gtk_window_get_resizeable (GtkWindow *window) return window->allow_grow; } - -/** - * gtk_window_set_size: - * @window: a #GtkWindow - * @width: width, or -1 to use the default width - * @height: height, or -1 to use the default height - * - * Sets the size of @window, but only works for resizeable windows - * (see gtk_window_set_resizeable()). Setting the size emulates a user - * resize operation. Therefore, setting the size less than the minimum - * size for the window will simply make the window its minimum size, - * and the user will be able to change the size that's set. - * - * This call also sets the default size of the window, so replaces - * gtk_window_set_default_size(). - * - * To set a minimum size, or to set the size of a non-resizeable window, - * use gtk_widget_set_usize() on the window. Though normally it makes - * more sense to instead call gtk_widget_set_usize() on a child widget inside - * the window, rather than the window itself. - * - * Under the X Window System, window managers are allowed to ignore GTK+'s - * request to change a window's size. So your program should not rely on - * getting a specific size. (And, as noted in gtk_window_get_size(), - * a program that crucially relies on a specific size will generally have - * race conditions and be buggy anyway - rather than assuming a - * call to gtk_window_set_size() has taken effect, you should react - * to configure_event signals on your #GtkWindow.) - * - * If you set a geometry widget for the window with - * gtk_window_set_geometry_hints(), the size applies to the geometry - * widget, not the window itself. - * - * If you've called the deprecated gtk_window_set_policy() function, - * gtk_window_set_size() may not behave as expected, due to interaction - * with window policies. - **/ -void -gtk_window_set_size (GtkWindow *window, - gint width, - gint height) -{ - g_return_if_fail (GTK_IS_WINDOW (window)); - g_return_if_fail (width != 0); - g_return_if_fail (height != 0); - - /* set_default_size() uses "0" to mean "unset", but we allow "-1" - * for that in this newer function - */ - if (width < 0) - width = 0; - if (height < 0) - height = 0; - - gtk_window_set_default_size (window, width, height); -} - -/** - * gtk_window_get_size: - * @window: a #GtkWindow - * @width: return location for current width, or %NULL - * @height: return location for current height, or %NULL - * - * Obtains the current size of @window. If the window is not onscreen - * (i.e. has not been received its first configure_event after being - * shown with gtk_widget_show()), the size will be the size GTK+ will - * request for this window when it's shown. The window manager may - * not choose to give the window exactly this requested size. - * - * In general, code which depends on window size should connect to the - * configure_event on the window so that it can respond to changes in - * size caused by the user or by the window manager, in addition to - * changes in size created by your program. - * - * If you set a geometry widget for the window with - * gtk_window_set_geometry_hints(), the size retrieved is the size of - * the geometry widget, not the window itself. - * - **/ -void -gtk_window_get_size (GtkWindow *window, - gint *width, - gint *height) -{ - GtkWindowGeometryInfo *info; - GtkWidget *widget = GTK_WIDGET (window); - - g_return_if_fail (GTK_IS_WINDOW (window)); - - if (GTK_WIDGET_REALIZED (window)) - { - gdk_window_get_size (GTK_WIDGET (window)->window, - width, height); - } - else - { - GdkGeometry new_geometry; - GdkWindowHints new_flags; - gint w, h; - - gtk_widget_size_request (widget, NULL); - gtk_window_compute_default_size (window, &w, &h); - - gtk_window_compute_hints (window, &new_geometry, &new_flags); - gtk_window_constrain_size (window, - &new_geometry, new_flags, - w, h, - &w, &h); - - if (width) - *width = w; - if (height) - *height = h; - } - - info = gtk_window_get_geometry_info (window, TRUE); - if (info->widget) - { - gint extra_width = widget->requisition.width - info->widget->requisition.width; - gint extra_height = widget->requisition.height - info->widget->requisition.height; - - if (width) - *width -= extra_width; - if (height) - *height -= extra_height; - } -} - -/** - * gtk_window_set_location: - * @window: a #GtkWindow - * @root_x: X position of gravity-determined reference point in root window coordinates - * @root_y: Y position of gravity-determined reference point in root window coordinates - * - * Requests a new position for a #GtkWindow. The position is given in - * root window coordinates, and is the position of the window's - * "reference point" as determined by the window gravity (see - * gtk_window_set_gravity()). By default, the reference point is the - * northwest (top left) corner of the window's titlebar. So if you - * set the window position to (0,0), the window's titlebar will end up - * in the top left corner of the root window. Note that the root - * window does not always correspond to the user's desktop area, so - * you may want to call gdk_workspace_get_extents() or - * gdk_desktop_get_extents() to decide where to place a window. The - * extents of the root window can be obtained using gdk_screen_width() - * and gdk_screen_height(). - * - **/ -void -gtk_window_set_location (GtkWindow *window, - gint root_x, - gint root_y) -{ - GtkWidgetAuxInfo *aux_info; - - g_return_if_fail (GTK_IS_WINDOW (window)); - - aux_info = _gtk_widget_get_aux_info (GTK_WIDGET (window), TRUE); - - aux_info->x_set = aux_info->y_set = TRUE; - aux_info->x = root_x; - aux_info->y = root_y; - - gtk_window_reposition (window, root_x, root_y); -} - -/** - * gtk_window_get_location: - * @window: a #GtkWindow - * @root_x: return location for X coordinate of gravity-determined reference point - * @root_y: return location for Y coordinate of gravity-determined reference point - * - * Attempts to obtain the current position of the reference point, as - * set by gtk_window_set_position(). This computation is accurate when - * the reference point is a corner of the window itself (as with - * #GDK_GRAVITY_STATIC), but may not be accurate when the reference - * point is a position on the titlebar or window border, because the X - * Window System does not provide a reliable way of obtaining this - * information. GTK+ will do a "best guess" which may not be fully - * accurate with some window managers, but will probably be - * reasonable. - * - **/ -void -gtk_window_get_location (GtkWindow *window, - gint *root_x, - gint *root_y) -{ - GdkRectangle frame_extents; - GtkWidget *widget; - GtkWidgetAuxInfo *aux_info; - - g_return_if_fail (GTK_IS_WINDOW (window)); - - widget = GTK_WIDGET (window); - - if (GTK_WIDGET_REALIZED (window)) - { - if (window->gravity == GDK_GRAVITY_STATIC) - { - gdk_window_get_origin (widget->window, root_x, root_y); - return; - } - else - { - gint x, y; - - gdk_window_get_frame_extents (widget->window, &frame_extents); - - x = frame_extents.x; - y = frame_extents.y; - - switch (window->gravity) - { - case GDK_GRAVITY_NORTH: - case GDK_GRAVITY_CENTER: - case GDK_GRAVITY_SOUTH: - x += frame_extents.width / 2; - break; - case GDK_GRAVITY_SOUTH_EAST: - case GDK_GRAVITY_EAST: - case GDK_GRAVITY_NORTH_EAST: - x += frame_extents.width; - break; - default: - break; - } - - switch (window->gravity) - { - case GDK_GRAVITY_WEST: - case GDK_GRAVITY_CENTER: - case GDK_GRAVITY_EAST: - y += frame_extents.height / 2; - break; - case GDK_GRAVITY_SOUTH_WEST: - case GDK_GRAVITY_SOUTH: - case GDK_GRAVITY_SOUTH_EAST: - y += frame_extents.height; - break; - default: - break; - } - - if (root_x) - *root_x = x; - if (root_y) - *root_y = y; - } - } - else - { - /* We really don't have a location yet, so we make up some stuff, - * using the uposition if it's been set. - */ - if (root_x) - *root_x = 0; - - if (root_y) - *root_y = 0; - - aux_info = _gtk_widget_get_aux_info (widget, FALSE); - if (aux_info && aux_info->x_set && aux_info->y_set) - { - *root_x = aux_info->x; - *root_y = aux_info->y; - } - } -} - /** * gtk_window_set_gravity: * @window: a #GtkWindow @@ -3713,7 +3423,7 @@ gtk_window_get_location (GtkWindow *window, * * Window gravity defines the "reference point" to be used when * positioning or resizing a window. Calls to - * gtk_window_set_position() will position a different point on the + * gtk_widget_set_uposition() will position a different point on the * window depending on the window gravity. When the window changes size * the reference point determined by the window's gravity will stay in * a fixed location. @@ -3728,11 +3438,11 @@ gtk_window_get_location (GtkWindow *window, * itself. * * The default window gravity is #GDK_GRAVITY_NORTH_WEST. - * + * **/ void gtk_window_set_gravity (GtkWindow *window, - GdkGravity gravity) + GdkGravity gravity) { g_return_if_fail (GTK_IS_WINDOW (window)); @@ -3740,9 +3450,7 @@ gtk_window_set_gravity (GtkWindow *window, { window->gravity = gravity; - /* This is sort of odd, but it keeps the hints recomputation - * in one place. Otherwise we're likely to mess up the - * recording of the last hints, etc. + /* gtk_window_move_resize() will adapt gravity */ gtk_widget_queue_resize (GTK_WIDGET (window)); } @@ -3751,9 +3459,9 @@ gtk_window_set_gravity (GtkWindow *window, /** * gtk_window_get_gravity: * @window: a #GtkWindow - * + * * Gets the value set by gtk_window_set_gravity(). - * + * * Return value: window gravity **/ GdkGravity @@ -3807,6 +3515,7 @@ gtk_window_begin_resize_drag (GtkWindow *window, timestamp); } + /** * gtk_window_begin_move_drag: * @button: mouse button that initiated the drag diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index f1460a6744..e4ed83eb49 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -47,8 +47,9 @@ extern "C" { #define GTK_WINDOW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_WINDOW, GtkWindowClass)) -typedef struct _GtkWindow GtkWindow; -typedef struct _GtkWindowClass GtkWindowClass; +typedef struct _GtkWindow GtkWindow; +typedef struct _GtkWindowClass GtkWindowClass; +typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo; struct _GtkWindow { @@ -58,15 +59,16 @@ struct _GtkWindow gchar *wmclass_name; gchar *wmclass_class; gchar *wm_role; - GtkWindowType type; - GdkWindow *frame; - GtkWidget *focus_widget; GtkWidget *default_widget; GtkWindow *transient_parent; + GtkWindowGeometryInfo *geometry_info; + GdkWindow *frame; - gushort resize_count; + guint16 resize_count; + + GtkWindowType type : 4; guint has_user_ref_count : 1; guint allow_shrink : 1; guint allow_grow : 1; @@ -90,11 +92,9 @@ struct _GtkWindow guint iconify_initially : 1; guint stick_initially : 1; guint maximize_initially : 1; - guint decorated : 1; GdkWindowTypeHint type_hint : 3; - GdkGravity gravity : 5; guint frame_left; @@ -145,26 +145,10 @@ void gtk_window_set_decorations_hint (GtkWindow *window, void gtk_window_set_functions_hint (GtkWindow *window, GdkWMFunction functions); - void gtk_window_set_resizeable (GtkWindow *window, - gboolean setting); + gboolean resizeable); gboolean gtk_window_get_resizeable (GtkWindow *window); - -void gtk_window_set_size (GtkWindow *window, - gint width, - gint height); -void gtk_window_get_size (GtkWindow *window, - gint *width, - gint *height); - -void gtk_window_set_location (GtkWindow *window, - gint root_x, - gint root_y); -void gtk_window_get_location (GtkWindow *window, - gint *root_x, - gint *root_y); - void gtk_window_set_gravity (GtkWindow *window, GdkGravity gravity); GdkGravity gtk_window_get_gravity (GtkWindow *window); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index cda2d5fec7..fd49da44d1 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -8252,7 +8252,8 @@ configure_event_callback (GtkWidget *widget, gchar *msg; gint x, y; - gtk_window_get_location (GTK_WINDOW (widget), &x, &y); + x = widget->allocation.x; + y = widget->allocation.y; msg = g_strdup_printf ("event: %d,%d %d x %d\n" "location: %d, %d", @@ -8289,8 +8290,7 @@ set_size_callback (GtkWidget *widget, get_ints (data, &w, &h); - gtk_window_set_size (g_object_get_data (data, "target"), - w, h); + gtk_window_set_default_size (GTK_WINDOW (g_object_get_data (data, "target")), w, h); } static void @@ -8325,8 +8325,7 @@ set_location_callback (GtkWidget *widget, get_ints (data, &x, &y); - gtk_window_set_location (g_object_get_data (data, "target"), - x, y); + gtk_widget_set_uposition (g_object_get_data (data, "target"), x, y); } static void @@ -8363,7 +8362,7 @@ static void gravity_selected (GtkWidget *widget, gpointer data) { - gtk_window_set_gravity (G_OBJECT (g_object_get_data (data, "target")), + gtk_window_set_gravity (GTK_WINDOW (g_object_get_data (data, "target")), gtk_option_menu_get_history (GTK_OPTION_MENU (widget)) + GDK_GRAVITY_NORTH_WEST); } @@ -8486,7 +8485,7 @@ window_controls (GtkWidget *window) while (i < 10) { GtkWidget *mi; - static gchar *names[10] = { + static gchar *names[] = { "GDK_GRAVITY_NORTH_WEST", "GDK_GRAVITY_NORTH", "GDK_GRAVITY_NORTH_EAST", diff --git a/tests/testgtk.c b/tests/testgtk.c index cda2d5fec7..fd49da44d1 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -8252,7 +8252,8 @@ configure_event_callback (GtkWidget *widget, gchar *msg; gint x, y; - gtk_window_get_location (GTK_WINDOW (widget), &x, &y); + x = widget->allocation.x; + y = widget->allocation.y; msg = g_strdup_printf ("event: %d,%d %d x %d\n" "location: %d, %d", @@ -8289,8 +8290,7 @@ set_size_callback (GtkWidget *widget, get_ints (data, &w, &h); - gtk_window_set_size (g_object_get_data (data, "target"), - w, h); + gtk_window_set_default_size (GTK_WINDOW (g_object_get_data (data, "target")), w, h); } static void @@ -8325,8 +8325,7 @@ set_location_callback (GtkWidget *widget, get_ints (data, &x, &y); - gtk_window_set_location (g_object_get_data (data, "target"), - x, y); + gtk_widget_set_uposition (g_object_get_data (data, "target"), x, y); } static void @@ -8363,7 +8362,7 @@ static void gravity_selected (GtkWidget *widget, gpointer data) { - gtk_window_set_gravity (G_OBJECT (g_object_get_data (data, "target")), + gtk_window_set_gravity (GTK_WINDOW (g_object_get_data (data, "target")), gtk_option_menu_get_history (GTK_OPTION_MENU (widget)) + GDK_GRAVITY_NORTH_WEST); } @@ -8486,7 +8485,7 @@ window_controls (GtkWidget *window) while (i < 10) { GtkWidget *mi; - static gchar *names[10] = { + static gchar *names[] = { "GDK_GRAVITY_NORTH_WEST", "GDK_GRAVITY_NORTH", "GDK_GRAVITY_NORTH_EAST", -- 2.30.2